package com.pansoft.hd.model;

import org.web3j.crypto.ECKeyPair;
import org.web3j.crypto.WalletFile;

/**
 * ETH钱包
 * Created by yqs97.
 * Date: 2019/11/1
 * Time: 15:06
 */
public class EthHdWallet extends BaseHDWallet {

    private ECKeyPair ecKeyPair;
    private WalletFile walletFile;

    public WalletFile getWalletFile() {
        return walletFile;
    }

    public void setWalletFile(WalletFile walletFile) {
        this.walletFile = walletFile;
    }

    public ECKeyPair getEcKeyPair() {
        return ecKeyPair;
    }

    public void setEcKeyPair(ECKeyPair ecKeyPair) {
        this.ecKeyPair = ecKeyPair;
    }


    public static final class EthHDWalletBuilder {
        //地址
        private String address;
        //私钥  10进制的
        private String privateKey;
        //公钥 10进制的
        private String publicKey;
        //文件路径
        private String filePath;
        private ECKeyPair ecKeyPair;
        private WalletFile walletFile;

        private EthHDWalletBuilder() {
        }

        public static EthHDWalletBuilder anEthHDWallet() {
            return new EthHDWalletBuilder();
        }

        public EthHDWalletBuilder withAddress(String address) {
            this.address = address;
            return this;
        }

        public EthHDWalletBuilder withPrivateKey(String privateKey) {
            this.privateKey = privateKey;
            return this;
        }

        public EthHDWalletBuilder withPublicKey(String publicKey) {
            this.publicKey = publicKey;
            return this;
        }

        public EthHDWalletBuilder withFilePath(String filePath) {
            this.filePath = filePath;
            return this;
        }

        public EthHDWalletBuilder withEcKeyPair(ECKeyPair ecKeyPair) {
            this.ecKeyPair = ecKeyPair;
            return this;
        }

        public EthHDWalletBuilder withWalletFile(WalletFile walletFile) {
            this.walletFile = walletFile;
            return this;
        }

        public EthHdWallet build() {
            EthHdWallet ethHDWallet = new EthHdWallet();
            ethHDWallet.setAddress(address);
            ethHDWallet.setPrivateKey(privateKey);
            ethHDWallet.setPublicKey(publicKey);
            ethHDWallet.setFilePath(filePath);
            ethHDWallet.setEcKeyPair(ecKeyPair);
            ethHDWallet.setWalletFile(walletFile);

            return ethHDWallet;
        }
    }
}
